package cn.hnbjx.prepaid.dao;

import cn.hnbjx.prepaid.pojo.NumData;
import cn.hnbjx.prepaid.pojo.UserHelp;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserHelpDao {

    @Select("select * from `user_help`  order by id desc")
    List<UserHelp> findAll(String key);
    @Select("select * from `user_help` where `accountId`=#{id} and `flag`=#{type}  order by id desc")
    List<UserHelp> apifindAll(@Param("type") Integer type,@Param("id") Integer id);
    @Select("select * from `user_help`  where `id` =#{id}")
    UserHelp findById(Integer id);

    @Insert("insert into user_help (accountId,address,location,flag,createTime,city) values (#{accountId},#{address},#{location},#{flag},now(),#{city})")
    void insert(UserHelp userHelp);
    @Update("update `user_help` set flag=#{flag} where id=#{id}")
    int updateFlag(@Param("flag") Integer flag, @Param("id") Integer id);
    @Select("select * from user_help where address like concat('%',#{key},'%') and flag<2 order by id desc")
    List<UserHelp> findByProvince(String key);
    @Select("select city,count(*) as num from user_help  group by city")
    List<NumData> findByNum();
}
